package com.sluggard.security.core.manage.mapping;

import org.springframework.web.bind.annotation.RequestMapping;

import java.lang.reflect.Method;
import java.util.Objects;

public class RequestMappingParser extends MappingParser {

    /**
     * 获取class RequestMapping的路径值
     */
    @Override
    public String[] getMapping(Class<?> declaringClass) {
        RequestMapping annotation = declaringClass.getAnnotation(RequestMapping.class);
        if (Objects.nonNull(annotation)) {
            return annotation.value();
        }
        return null;
    }

    /**
     * 获取method RequestMapping的路径值
     */
    @Override
    public String[] getMapping(Method method) {
        RequestMapping annotation = method.getAnnotation(RequestMapping.class);
        if (Objects.nonNull(annotation)) {
            return annotation.value();
        }
        return null;
    }

}
